/*
  原型链继承

  如果父类中的属性是引用类型就会导致公用一个引用类型
*/ 

function Father () {
  this.name = 'father'
  this.types = ['武侠','言情','玄幻']
}

Father.prototype.sayName = function () {
  console.log(this.name)
}

function Son (age) {
  this.age = age
}

Son.prototype = new Father()

Son.prototype.sayAge = function () {
  console.log(this.age)
}
Son.prototype.sayTypes = function () {
  console.log(this.types)
}

let mySon = new Son(20)
let mySon2 = new Son(22)
console.log(mySon)
mySon.sayName()
mySon.sayAge()
mySon.types.push('漫画')
mySon.sayTypes()


mySon2.sayName()
mySon2.sayAge()
mySon2.sayTypes()